<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>事件冒泡</title>
		<script src="../js/jquery-3.4.1.min.js"></script>
		<script>
			$(function(){
				//阻止事件的冒泡的功能
				$("#a3").click(function(){
					return false;
				});
			});
		</script>
		<script>
			//冒泡
			//如何阻止事件冒泡？
			function do1(e){ 
				alert(1);
				//>>>alert(e.srcElement);
				//e=window.event|event;
				if (e && e.stopPropagation)  
				     e.stopPropagation()  
				else  
					window.event.cancelBubble=true  
				
			}
			function do2(){
				
				alert(2);
			}
		</script>
	</head>
	<body>
		<div id="d1" onclick="do2()">
			<span onclick="do1()" style="cursor: pointer;">dazhahao</span>
			<hr/>
			<a href="https://www.baidu.com" id="a3">百度</a>
		</div>
		
	</body>
</html>
